package data;

import java.util.Date;

import com.EntityName;
import com.google.appengine.api.datastore.Entity;

public class POSHistory extends AbstractData {

	private transient long id = -1;
	private String change;
	private String title;
	private String user;
	private Date stampDate;
	
	public POSHistory() {}
 
	public POSHistory( long id) {
		this.id = id;
	}
	
	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getChange() {
		return change;
	}

	public void setChange(String change) {
		this.change = change;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}


	public Date getStampDate() {
		return stampDate;
	}


	public void setStampDate(Date stapDate) {
		this.stampDate = stapDate;
	}

	public String getUser() {
		return user;
	}


	public void setUser(String user) {
		this.user = user;
	}

	@Override
	public Entity getEntity() {
	
		Entity item;
		if(this.key == null)
			item = new Entity(EntityName.POSHistory);
		else
			item = new Entity(this.key);
	
		item.setProperty("title", this.title);
		item.setProperty("change", this.change);
		item.setProperty("stampDate", this.stampDate);
		item.setProperty("user", this.user);
		
		return item;
		
	}
	
	@Override
	public void setEntity(Entity entity) {
		this.id = entity.getKey().getId();
		this.title = (String) entity.getProperty("title");
		this.change = (String) entity.getProperty("change");
		this.stampDate = (Date) entity.getProperty("stampDate");
		this.user = (String) entity.getProperty("user");
	
		this.key = entity.getKey();
	}
	
	public void LoadData() {
		if (this.id > -1) {
			Entity entity = LoadData(EntityName.POSHistory, this.id);
			setEntity(entity);
		}
	}
}
